/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-22 09:22:54
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-22 15:26:29
 * @FilePath: \adminstration\src\Common\Modal\TwoModalList\SampleParameter.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../Api/Api'
import { commonTableList } from '../config'
import { setValueEnumData } from '../../Router/MenuBoxList'
import { TwoAddBtn, ThrDeleteBtn, SeeQRcodeBtn, ExportExcelBtn, OpenThrBtn } from '../options'
export const SampleParameter = async ({ upDataEvent, data, Permission }) => {
    let dataList = {
        type: '配置检测参数',
        hideInSearch: true,
        pageSize: 10,
        params: {},
        classification: 'TableModal',
        get: API_LIST([data.uuid])['getSampleItem'],
        additional: { key: 'SampleUuid', value: 'uuid' },
        options: [
            Permission.findIndex(v => v.uuid === 'c57f2472-8450-411b-b79a-a17d64fa8dc7') !== -1 && (
                <TwoAddBtn
                    upDataEvent={upDataEvent}
                    title="添加检测报告"
                    ThrKey="ThrModal"
                    value="SampleParameter"
                    data={data}
                />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'sampleUuid',
                title: '样品编号',
                type: 'hidden',
                hideInTable: true,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                width: 150,
            },
            {
                dataIndex: 'displayNo',
                title: '样品编号',
                type: 'hidden',
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                width: 200,
            },
            {
                dataIndex: 'serialNo',
                title: '报告编号',
                type: 'hidden',
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                width: 200,
            },
            {
                dataIndex: 'labReportTemplateUuid',
                title: '报告名称',
                valueType: 'select',
                valueEnum: {},
                rules: true,
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'selectedTestTypeNames',
                title: '检测参数',
                type: 'hidden',

                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                width: 300,
            },

            {
                dataIndex: 'tableName',
                title: '样品名称',
                valueType: 'input',
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'spec',
                title: '规格型号',
                valueType: 'input',
                hideInSearch: true,
                width: 100,
            },
            {
                dataIndex: 'num',
                title: '数量',
                valueType: 'inputNumber',
                rules: true,
                hideInSearch: true,
                width: 100,
            },
            {
                dataIndex: 'unit',
                title: '单位',
                valueType: 'input',
                hideInSearch: true,
                rules: true,
                width: 100,
            },
            {
                dataIndex: 'sampleDisposal',
                title: '样品处置',
                valueType: 'input',
                hideInSearch: true,
                width: 100,
            },
            {
                dataIndex: 'factoryName',
                title: '厂家名称',
                valueType: 'input',
                hideInSearch: true,
                width: 300,
            },
            {
                dataIndex: 'factorySerialNo',
                title: '出厂编号',
                valueType: 'input',
                hideInSearch: true,
                width: 200,
            },
            {
                dataIndex: 'factoryDate',
                title: '出厂日期',
                valueType: 'Date',
                hideInSearch: true,
                showTime: true,
                width: 200,
            },
            {
                dataIndex: 'standardModifyNo',
                title: '报告唯一性标识',
                valueType: 'input',
                width: 200,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 350,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '3d252f6f-a9dc-4877-99e7-269b87548256') !== -1 && (
                            <SeeQRcodeBtn
                                key="qrcode"
                                data={{
                                    className: 'Admin',
                                    key: 'SampleParameter',
                                    record,
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '5fa502ed-1a4a-4fb7-8884-a0543195060b') !== -1 && (
                            <ExportExcelBtn
                                key="task"
                                title="下载报告"
                                api={API_LIST()['getLabReport']}
                                data={{ SampleItemUuid: record.uuid }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === '6c3362be-bdc7-4e6a-bbab-baa01cca911e') !== -1 && (
                            <OpenThrBtn
                                key="openThr"
                                upDataEvent={upDataEvent}
                                title="试验详情"
                                ThrKey="ThrModal"
                                value="SampleParameterDetails"
                                data={record}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === 'fd24d09d-a6f0-4f11-b7dd-ede0c2e7936a') !== -1 && (
                            <ThrDeleteBtn
                                key="delete"
                                record={record.uuid}
                                upDataEvent={upDataEvent}
                                data={{ key: 'delete', url: 'delSampleItem', title: '删除报告' }}
                            />
                        ),
                    ]
                },
            },
        ],
    }

    dataList.columns.find(v => v.dataIndex === 'labReportTemplateUuid').valueEnum = await setValueEnumData({
        url: 'getLabReportTemplates',
    })
    return dataList
}
